﻿using Microsoft.VisualStudio.TestTools.UnitTesting;

[TestClass]
public class RectangleTest
{
    [TestMethod]
    public void CloneTest()
    {
        Rectangle target = new Rectangle(1, 2, 3, 4);
        object expected = new Rectangle(1, 2, 3, 4);
        object actual = target.Clone();
        Assert.AreEqual(((Rectangle)expected).X, ((Rectangle)actual).X);
        Assert.AreEqual(((Rectangle)expected).Y, ((Rectangle)actual).Y);
        Assert.AreEqual(((Rectangle)expected).Width, ((Rectangle)actual).Width);
        Assert.AreEqual(((Rectangle)expected).Height, ((Rectangle)actual).Height);
        Assert.AreNotSame(actual, target);
    }

    [TestMethod]
    public void CompareToBiggerTest()
    {
        Rectangle target = new Rectangle();
        Rectangle other = new Rectangle(1, 1, 2, 2);
        int expected = 0.CompareTo(4);
        int actual = target.CompareTo(other);
        Assert.AreEqual(expected, actual);
    }

    [TestMethod]
    public void CompareToSmallerTest()
    {
        Rectangle target = new Rectangle(1, 1, 2, 2);
        Rectangle other = new Rectangle(1, 1, 1, 1);
        int expected = 4.CompareTo(1);
        int actual = target.CompareTo(other);
        Assert.AreEqual(expected, actual);
    }

    [TestMethod]
    public void CompareToSimilarTest()
    {
        Rectangle target = new Rectangle(3, 3, 3, 2);
        Rectangle other = new Rectangle(1, 1, 2, 3);
        int expected = 6.CompareTo(6);
        int actual = target.CompareTo(other);
        Assert.AreEqual(expected, actual);
    }

    [TestMethod]
    public void CompareToSimilarZeroTest()
    {
        Rectangle target = new Rectangle();
        Rectangle other = new Rectangle();
        int expected = 6.CompareTo(6);
        int actual = target.CompareTo(null);
        Assert.AreEqual(expected, actual);
    }
}
